package com.yc.controller;


import com.yc.entity.Pmap;
import com.yc.mapper.PmapMapper;
import com.yc.service.IPmapService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * InnoDB free: 4096 kB 前端控制器
 * </p>
 *
 * @author ly
 * @since 2022-05-25
 */
@Controller
@RequestMapping("/pmap")
public class PmapController {
    @Resource
    private PmapMapper pmapMapper;
    @Resource
    private IPmapService iPmapService;

    @RequestMapping("queryByCtid")
    @ResponseBody
    public List< Pmap > queryByCtid(Integer ctid){
        return iPmapService.queryByCtid(ctid);
    }

    @RequestMapping("queryPname")
    @ResponseBody
    public List<Pmap> queryPname(Integer ctid){
        return pmapMapper.queryPname(ctid);
    }

    @RequestMapping("queryPlayAddress")
    @ResponseBody
    public List<Pmap> queryPlayAddress(Integer ctid,String pname,String cpname){
        return pmapMapper.queryPlayAddress(ctid,pname,cpname);
    }

    @RequestMapping("deleteByCtid")
    @ResponseBody
    public Integer deleteByCtid(Integer ctid,String pname){
        if ( pname!=null ){
            return pmapMapper.deleteByCtidAndPname(ctid,pname);
        }else {
            return pmapMapper.deleteByCtid(ctid);
        }
    }

    @RequestMapping("addPmap")
    @ResponseBody
    public Integer addPmap(@RequestBody List<Pmap> list){
        return iPmapService.addPmap(list);
    }

    @RequestMapping("update")
    @ResponseBody
    public Integer update(@RequestBody List<Pmap> list){
        return iPmapService.update(list);
    }

    @RequestMapping("queryByPid")
    @ResponseBody
    public List<Pmap> queryByPid(Integer pid){
        return pmapMapper.queryByPid(pid);
    }
}

